<?php

require(__META_CONTROLS_GEN__ . '/OrgMetaControlGen.class.php');


class OrgMetaControl extends OrgMetaControlGen {

    protected $txtAOrg;
    protected $txtAOracleLink;
    protected $dttTime;

    public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
        $intId = QApplication::PathInfo(0);

        return OrgMetaControl::Create($objParentObject,  QS_DECODE($intId), $intCreateType);
    }

    public function txtAOracleLink_Create($strControlId = null) {
        $this->txtAOracleLink = new QAjaxAutoCompleteTextBox($this->objParentObject, 'txtAOracleLink_Change',$strControlId);
        $this->txtAOracleLink->Name = QApplication::Translate("<a href='". __CONTACTS__ . "/Organization_edit.php' target='_blank'>School Oracle Number</a>");
        $this->txtAOracleLink->MustMatch=true;

        //if($this->objPerson->OrgId) $this->txtOrg->Text = $this->objPerson->Org->__toString();
        return $this->txtAOracleLink;
    }

    public function txtAOrg_Create($strControlId = null) {
        $this->txtAOrg = new QAjaxAutoCompleteTextBox($this->objParentObject, 'txtAOrg_Change',$strControlId);
        $this->txtAOrg->Name = QApplication::Translate("<a href='". __CONTACTS__ . "/Organization_edit.php' target='_blank'>School</a>");
        $this->txtAOrg->MustMatch=true;
        //if($this->objPerson->OrgId) $this->txtOrg->Text = $this->objPerson->Org->__toString();
        //$this->txtAOrg->MaxLength = Org::NameMaxLength;
        return $this->txtAOrg;
    }

    public function SaveOrg() {
        parent::SaveOrg();

        try {
            $this->dttTime = new QDateTime();
            $this->dttTime->setDate (date("Y"), date("m"), date("d"));
            $this->dttTime->setTime (date("H"), date("i"), date("s"));

            $CurrentUser = $_SESSION['User']['Id'];

            if ($this->blnEditMode) {
                //Updating
                $this->objOrg->UpdateBy   = $CurrentUser;
                $this->objOrg->UpdateDate = $this->dttTime;
            }
            else {
                //New
                $this->objOrg->CreateBy   = $CurrentUser;
                $this->objOrg->CreateDate = $this->dttTime;
            }
            $this->objOrg->Save();

        } catch (QCallerException $objExc) {
            $objExc->IncrementOffset();
            throw $objExc;
        }
    }



}
?>
